<button type="button" onclick="importExcel()" class="btn btn-default navbar-btn">导出本页面</button>


<script type="text/javascript">
    function importExcel() {
        var thead = []
        var tbody = []
        //获取表格内容
        $("[aria-describedby*='grid-table_']").each(function () {
            var _this = $(this);
            if (_this.css("display") != "none") {
                var a = (_this.attr("aria-describedby"))
                if (a != "grid-table_rn" && a != "grid-table_cb") {
                    tbody.push(_this.text())
                }
            }
        });
        //获取表头信息
        $(".ui-jqgrid-sortable").each(function () {
            var _this = $(this);
            if (_this.parent().css("display") != 'none') {
                thead.push(_this.text())
            }
        })
        var c = new Date().getTime();
        $.post("${ctxPath}/import", {
            thead: thead,
            tbody: tbody,
            c: c
        }, function (d) {
            window.location.href = "${ctxPath}/export?c=" + c + "&code=" +"${code}";
            window.top.layer.alert("导出成功", {icon: 1, title: "成功"});
        });
    }
</script>
